home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
usenet
/
st80_pre4
/
EnvVarFileList.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
2KB
|
68 lines
" NAME EnvVarFileList
AUTHOR kww@cs.glasgow.ac.uk (Dr Kevin Waite)
FUNCTION Allows UNIX environment variables in FileListViews
ST-VERSIONS 2.5
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION 1.1
DATE 10 Sep 90
SUMMARY The following file-in allows UNIX shell environment variables to be
entered as the root of a file name in a FileListView. For example,
if I enter:
$HOME/bin
I get to browse the files in directory /users/iii/kww/bin. This greatly
simplifies the browsing of files in important directories. Note that the
file-in extends only the UnixFilename class.
"
!
"
Newsgroups: comp.lang.smalltalk
Message-ID: <6254@vanuata.cs.glasgow.ac.uk>
Date: 10 Sep 90 14:55:08 GMT
Organization: Computing Sci, Glasgow Univ, Scotland
Email: kww@uk.ac.glasgow.cs (JANET)
kww%cs.glasgow.ac.uk@nsfnet-relay.ac.uk (INTERNET)
Address: Dept. of Computing Science, University of Glasgow,
17 Lilybank Gardens, Glasgow, United Kingdom. G12 8QQ
"
'From Objectworks for Smalltalk-80(tm), Version 2.5 of 29 July 1989 on 10 September 1990 at 3:55:59 pm'!
!UnixFilename class methodsFor: 'private'!
baseDirectoryForList: list
^list first = (String with: self separator)
ifTrue: [self named: list removeFirst]
ifFalse: [list first first = $$
ifTrue: [self lookupEnvironment: list]
ifFalse: [self currentDirectory]]!
lookupEnvironment: list
"The first member of this list starts with a dollar sign and therefore
could be a dereferencing of a UNIX environment variable. Lookup this
variable in the current environment and if it is there use its value as
the directory root, otherwise treat the dollar as an ordinary character."
| environ key value root |
environ := CEnvironment userEnvironment.
key := list first copyFrom: 2 to: list first size.
value := environ at: key ifAbsent: [^self currentDirectory].
root := self named: value.
(root exists and: [root isDirectory]) ifFalse: [
^self currentDirectory].
"The first part of the given name did correspond to an environment
variable with a legal directory name as its value. Use that directory
as the base directory and strip off the name from the component list."
list removeFirst.
^root! !